import API from '../../utils/api'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    activityList: [],
    page:1,
    isLoading:false,
    noData:false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      activityList: []
    })
   this.weekActivity(1)
  
  },
weekActivity (page) {
  var data = {
    areaid: wx.getStorageSync('childid'),
      page: page,
      pagesize: 10
  }
  API.activeWeekend(data).then(res=>{
    console.log(res)
    if (res.code == 0) {
      if (res.data.length >0) {
        this.setData({
          isLoading:true
        })
      } else {
        this.setData({
          noData:true,
          isLoading:false
        })
      }
      var dealData = this.data.activityList.concat(res.data)
      this.setData({
        activityList: dealData
      })
    }
  })
},
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    var page = this.data.page
    page++
    this.setData({
      page:page
    })
    this.weekActivity(page)
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})